package co.gov.medellin.ssti.sub.model.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import co.gov.medellin.ssti.sub.model.dao.IErrorDAO;
import co.gov.medellin.ssti.sub.model.dao.exception.DAOException;

public class ErrorDAOImpl extends BaseDAOImpl implements IErrorDAO {
	private static final String INSERT_BEN_REGISTRO_ERRORES = "INSERT INTO TCS_BEN_REGISTRO_ERRORES "
			+ "(CODIGO, NOMBRE, DESCRIPCION) "
			+ "VALUES (SCS_BEN_RER.NEXTVAL, ?,?)";

	public ErrorDAOImpl(Connection con) {
		super(con);
	}

	public int insertError(String strName, String strDescription)
			throws DAOException {
		PreparedStatement pstmt = null;

		try {
			pstmt = conn.prepareStatement(INSERT_BEN_REGISTRO_ERRORES);
			pstmt.setString(1, strName);
			pstmt.setString(2, strDescription);
			return pstmt.executeUpdate();
		} catch (SQLException e) {
			throw new DAOException(e);
		} finally {
			close(pstmt);
		}
	}
}
